package com.xueshishasha.oa.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.xueshishasha.oa.common.utils.PageModel;

public interface DataService<E> {

	/**
	 * 持久化对象
	 * @param e
	 * @return
	 */
	public Serializable save(E e);
	
	public void delete(E e);

	public void update(E e);
	
	public E getModelById(Class<E> clazz, Serializable id);

	public void saveOrUpdate(E e);

	public void saveOrUpdateAll(Collection<E> ce);
	
    public List<E> getModels(String sql, Object[] parameters);
    
    public E getModel(String sql,Object[] parameters);
    
    //public List<Employee> getModelsByCriteria();
    
    public List<E> getByCriteria(DetachedCriteria dc);
    
    public Long getCount(Class<E> clazz);
    

	/**
	 * 返回满足DetachedCriteria条件的所有元素
	 * @param detachedCriteria 条件
	 * @return
	 */
	public List<E> findAllByCriteria(final DetachedCriteria detachedCriteria);
	
	/*=====================分页查询=======================*/
	
	public PageModel list(final String hql, final Object[] paras,
			final int offset, final int count);
    
}